<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>后台管理系统</title>
    <meta name="author" content="BaiYY"/>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/Font/css/font-awesome.min.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/index.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/pages.css"/>
    <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/index.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/time.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/pages.js"></script>
</head>
<body>
    <div class="right-sidebar" style="max-width: 1200px;">
        <ul class="nav nav-tabs" style="margin-bottom: 16px" role="tablist">
            <li role="presentation"><a href="myNext.html">下级详情</a></li>
            <if condition='$review eq 1'>
                <li role="presentation" class="active"><a href="myNextCheck.html">下级审核</a></li>
            </if>
            <li role="presentation"><a href="myNextSearch.html">下级查询</a></li>
            <if condition='$role lt $player'>
                <li role="presentation" id="playerole"><a href="playerSearch.html">{:L(GAME_SETTING_PLAYER)}</a></li>
            </if>
        </ul>
        <div class="admin_tab_cont" style="display:block;" id="tab1">
            <section class="table-responsive">
                <table class="table" style="border: 1px solid #ddd;">
                    <thead>
                    <tr id="head">
                        <th>玩家ID</th>
                        <th>手机号码</th>
                        <th>真实姓名</th>
                        <th>注册时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody id="dataList"></tbody>
                </table>
            </section>
            <div style="width: 100%;">
                <ul class="page" id="page" style="width: 100%;overflow: hidden;"></ul>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $(function () {
            var values = $("#playerole").text();
            if($.trim(values) == '' || $.trim(values) == 'GAME_SETTING_PLAYER') {
                $("#playerole").hide();
            }

            $.ajax({
                type:"post",
                url:"{:U('Admin/Main/myNextCheckPage')}",
                success:function(datas){
//                    console.log(datas);
                    if(datas == 'nodata') {
                        $("#dataList").html("暂时没有数据");
                    }else{
                        options={
                            "id":"page",//显示页码的元素
                            "data":datas,//显示数据
                            "maxshowpageitem":2,//最多显示的页码个数
                            "pagelistcount":10,//每页显示数据个数
                            "callBack":function(data){
//                                    console.log(data);
                                var str = '';
                                for(var i=0;i<data.length;i++) {
                                    str += "<tr><td class='user_id'>"+data[i].user_id+"</td><td>"+data[i].tel+"</td><td>"+data[i].name+"</td><td>"+getLocalTime(data[i].create_time)+"</td><td><button class='btn btn-primary' onclick='passClick(this)'>通过</button> <button class='btn btn-primary' onclick='delClick(this)'>删除</button></td></tr>"
                                }
                                $("#dataList").html(str);
                            }
                        }
                        page.init(datas.length,1,options);
                    }
                }
            })
        })
        function passClick(This) {
            var user_id = $(This).closest("tr").find("td.user_id").text();
           if(confirm("确认让此人加盟代理？")) {
               $.ajax({
                   type:"get",
                   url:"{:U('Admin/Main/myNextCheckPass')}?user_id="+user_id,
                   success: function (data) {
                       if(data == 'success') {
                           alert("审核通过");
                           window.location.href = "{:U('Admin/Main/myNextCheck')}";
                       }else if(data == 'error') {
                           alert("抱歉，审核未通过！");
                           window.location.href = "{:U('Admin/Main/myNextCheck')}";
                       }
                   }
               })
           }
        }

        function delClick(This) {
            var user_id = $(This).closest("tr").find("td.user_id").text();
            if(confirm('确定要删除该加盟代理吗？')) {
                $.ajax({
                    type:"get",
                    url:"{:U('Admin/Main/myNextCheckDel')}?user_id="+user_id,
                    success: function (data) {
                        if(data == 'success') {
                            alert("删除成功");
                            window.location.href = "{:U('Admin/Main/myNextCheck')}"
                        }else if(data == 'error') {
                            alert("删除失败");
                        }
                    }
                })
            }
        }
    </script>
</body>
</html>